package core;

import java.util.Date;

public abstract class BaseDecision {

	protected PersonAccount m_account;

	protected Date m_last_time;

	protected Date m_current_time;

	protected float m_buy_price;

	protected float m_sell_price;

	protected float m_moving_ave_price;

	public BaseDecision(PersonAccount account) {
		m_account = account;
		m_last_time = null;
	}

	public void Update(float buy_price, float sell_price, float moving_ave_price, Date date) {
		m_account.updateGoods(buy_price, sell_price);
		m_buy_price = buy_price;
		m_sell_price = sell_price;
		m_moving_ave_price = moving_ave_price;

		MakeDecision(moving_ave_price, date);
	}

	public void MakeDecision(float moving_ave_price, Date date) {
		if (null == m_last_time) {
			m_last_time = date;
		}
		m_current_time = date;

		JudgeSell();

		JudgeBuy();

		m_last_time = m_current_time;
	}

	protected abstract boolean JudgeSell();

	protected abstract boolean JudgeBuy();
}
